// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__38A80E1F_AB9E_4E7D_8E31_4C02BBAB78E4__INCLUDED_)
#define AFX_STDAFX_H__38A80E1F_AB9E_4E7D_8E31_4C02BBAB78E4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


// Insert your headers here
#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers

#include <windows.h>

//////////////////////////////////////////////////////////////////////////
/// The following is cited from SampleCAI.
//////////////////////////////////////////////////////////////////////////
#if defined ( _MSC_VER ) && _MSC_VER >= 1400
#   define _CRT_SECURE_NO_WARNINGS 1     // Get the compiler to *shut*
#   define _CRT_SECURE_NO_DEPRECATE 1    // *up* about deprecated CRT
#endif                                   // functions...

#ifndef STRICT
# define STRICT                          // Turn on strict(er) type-
#endif // ! STRICT                       // checking in Windows headers

#ifndef _ATL_APARTMENT_THREADED
# define _ATL_APARTMENT_THREADED         // Select level of thread-
#endif // not Apartment Threaded         // safety for this server

#ifdef _DEBUG
# define _ATL_DEBUG_QI                   // Turn on ATL QI tracing
#endif // _DEBUG

#ifndef _ATL_NO_AUTOMATIC_NAMESPACE
# define _ATL_NO_AUTOMATIC_NAMESPACE     // Don't use the entire ATL
#endif // ! _ATL_NO_AUTOMATIC_NAMESPACE  // namespace

#ifndef _ATL_STATIC_REGISTRY
# define _ATL_STATIC_REGISTRY            // Static link to the ATL lib
#endif // ! _ATL_STATIC_REGISTRY

#ifndef ATLBASE_H_INCLUDED
# include <atlbase.h>                    // Core ATL classes (that don't
# define ATLBASE_H_INCLUDED              // depend on _Module)
#endif // not <atlbase.h>

#ifndef ATLCOM_H_INCLUDED
# include <atlcom.h>                     // ATL support for building COM
# define ATLCOM_H_INCLUDED               // servers
#endif // not <atlcom.h>

#ifndef ATLCTL_H_INCLUDED
# include <atlctl.h>                     // ATL control support
# define ATLCTL_H_INCLUDED
#endif // not <atlctl.h>

using namespace ATL;                     // Normally I'd never put a
                                         // using declaration in a
                                         // header; this seems to be
                                         // commonly used, however.

#ifndef STRING_INCLUDED
# include <string>                       // For class std::string
# define STRING_INCLUDED
#endif // not <string>

#ifndef ADDAUTO_H_INCLUDED
# include <ADDAUTO.H>                    // DevStudio 6.0 AddIn
# include <appauto.h>
// There may be some compile error about "bool" in dbgauto.h. 
// To resolve it just rename those 'bool' to be any other name.
#include <bldauto.h>
# include <dbgauto.h>
# define ADDAUTO_H_INCLUDED              // interfaces
#endif // not ADDAUTO_H_INCLUDED

// #ifndef ADDGUID_H_INCLUDED
// # include <ADDGUID.H>                    // DevStudio 6.0 Addin UUIDs
// # define ADDGUID_H_INCLUDED
// #endif // not ADDGUID_H_INCLUDED
// 
// #ifndef APPGUID_H_INCLUDED
// # include <APPGUID.H>                    // DevStudio 6.0 Object model
// # include <DBGGUID.H>
// # define APPGUID_H_INCLUDED              // UUIDs
// #endif // not APPGUID_H_INCLUDED

#pragma warning (push, 3)                // It's just easier to dial the
                                         // compiler warning level down
                                         // for these #imports (since I
                                         // can't do anything about
                                         // them, anyway).

// For Visual Studio Command Bar interfaces
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\vsmso.olb
#import "libid:1CBA492E-7263-47BB-87FE-639000619B15" version("8.0")    \
  lcid("0") raw_interfaces_only named_guids

// For the DTE interface
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\dte80a.olb
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0")    \
  lcid("0") raw_interfaces_only named_guids                            \
  rename("FindText",    "dte80aFindText")                              \
  rename("GetObject",   "dte80aGetObject")                             \
  rename("ReplaceText", "dte80aReplaceText")                           \
  rename("SearchPath",  "dte80aSearchPath")

// For the DTE80 interface
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\dte80.olb
#import "libid:1A31287A-4D7D-413e-8E32-3B374931BD89" version("8.0")    \
  lcid("0") raw_interfaces_only named_guids

#pragma warning (pop)

namespace MSVSCBs = Microsoft_VisualStudio_CommandBars; 

#define HANDLE_COM_ERROR(clsid, iid, hr)                             \
  catch (const _com_error &ex)                                       \
  {                                                                  \
    LPCTSTR lpszMsg = NULL;                                          \
    _bstr_t bstrDsc = ex.Description();                              \
    if (0 != bstrDsc.length()) lpszMsg = bstrDsc;                    \
    else                       lpszMsg = ex.ErrorMessage();          \
    hr = AtlReportError((clsid), lpszMsg, (iid), ex.Error());        \
  }

#define HANDLE_EXCEPTION(clsid, iid, hr)                             \
  catch (const std::exception &ex)                                   \
  {                                                                  \
    hr = AtlReportError((clsid), ex.what(), (iid), E_FAIL);          \
  }

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__38A80E1F_AB9E_4E7D_8E31_4C02BBAB78E4__INCLUDED_)
